@if  defined AUTOCONF_ROOT goto :AUTOCONF_ROOT_SKIP
    @pushd %~dp0
    @SET AUTOCONF_ROOT=%CD%
    @popd
:AUTOCONF_ROOT_SKIP

       @if /i {%1}=={init} @(
    @shift
    @goto :BUILDWND_START 
) else @(
    @cmd/k %0 init
)

@goto :EOF

:BUILDWND_START

  @SET PROJECT_ROOT=%CD%

  @if exist        envconf.bat         @(
     @call         envconf.bat          
  ) else if exist ..\envconf.bat       @(
     @call         ..\envconf.bat       
  ) else if exist ..\..\envconf.bat    @(
     @call         ..\..\envconf.bat    
  ) else if exist ..\..\..\envconf.bat @(
     @call         ..\..\..\envconf.bat 
  ) else @(
     @echo envconf.bat not found
     @goto :EOF
  )

  @if not defined MSVC_HOME @(
     @echo MSVC not found
     @goto :EOF
  )

  @if not defined JAVA_HOME @(
     @echo JAVA not found
     @goto :EOF
  )

  @if not defined PROJECT_DEBUG set PROJECT_DEBUG=release

@rem  setup for MSVC

  @SET MSVC_DEVENV=%MSVC_HOME%\Common7\IDE\DEVENV.EXE
  @call %MSVC_HOME%\VC\VCVARSALL.BAT x86

  @if exist %PROJECT_ROOT%\win\vc%MSVC_VERSION% @(
    @set MSVC_PROJECT_ROOT=%PROJECT_ROOT%\win\vc%MSVC_VERSION%
  ) else if exist %PROJECT_ROOT%\win @(
    @set MSVC_PROJECT_ROOT=%PROJECT_ROOT%\win
  ) 


@rem finished
  @title Build Window(%PROJECT_NAME%--%PROJECT_DEBUG%,VC%MSVC_VERSION%)

  @SET MY_PATH=%PROJECT_ROOT%;%AUTOCONF_ROOT%;

  @if defined TOOL_HOME  SET MY_PATH=%MY_PATH%;%TOOL_HOME%
  @if defined ENTRY_ROOT SET MY_PATH=%MY_PATH%;%ENTRY_ROOT%
  
  @PATH %MY_PATH%;%JAVA_HOME%\bin;%MSVC_HOME%\VC;%MSVC_HOME%\Common7\IDE;%PATH%;

@rem custom setting
  @call project_cfg.bat                2>nul
  @call project_cfg.%COMPUTERNAME%.bat 2>nul
  @call project_cfg.local.bat          2>nul

@goto :EOF